package com.cloud.bc.model.enums;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public enum PaymentTypeEnum {
    MEMBER(1, "会员充值"),
    GIFT(2, "购买礼物"),
    ;
    private int code;
    private String desc;

    PaymentTypeEnum(int code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public int getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    public static PaymentTypeEnum getEnum(String desc) {
        for (PaymentTypeEnum c : PaymentTypeEnum.values()) {
            if (c.getDesc().equals(desc)) {
                return c;
            }
        }
        return null;
    }

    public static PaymentTypeEnum getEnum(int index) {
        for (PaymentTypeEnum c : PaymentTypeEnum.values()) {
            if (c.getCode() == index) {
                return c;
            }
        }
        return null;
    }

    public static List<Map<String, String>> getAllEnum() {
        List<Map<String, String>> list = new ArrayList<>();
        for (PaymentTypeEnum c : PaymentTypeEnum.values()) {
            Map<String, String> map = new HashMap<String, String>();
            map.put("value", c.getCode() + "");
            map.put("label", c.getDesc());
            list.add(map);
        }
        return list;
    }

}
